const Koa=require('koa')
const app=new Koa()
const userRouter=require('./router/user.js')
const petRouter=require('./router/Pet.js')

const cors=require('@koa/cors')
const {bodyParser}=require('@koa/bodyparser')
app.use(cors())//告诉浏览器，运行前端跨域请求我
app.use(bodyParser())//解析请求体



app.use(userRouter.routes(),userRouter.allowedMethods())
app.use(petRouter.routes(),petRouter.allowedMethods())

// app.use(async(ctx)=>{
//     console.log(ctx)
 
//     if(ctx.request.url==='/home'){
//         ctx.body='home'
//     }
// })
app.listen(3000,()=>{
    console.log('server is running at http://localhost:3000')
})

